package com.xmtlxx.wms.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xmtlxx.common.annotation.DataColumn;
import com.xmtlxx.common.annotation.DataPermission;
import com.xmtlxx.common.core.mapper.BaseMapperPlus;
import com.xmtlxx.wms.domain.SmartCabinetCode;
import com.xmtlxx.wms.domain.bo.VerifyOpenAllCabinetBo;
import com.xmtlxx.wms.domain.bo.VerifyOutProBo;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author hergreen
 * @description 针对表【T_PICK_OUT_WAREHOUSE_CODE(挑拣出库验证码)】的数据库操作Mapper
 * @createDate 2024-08-23 15:25:07
 * @Entity com.xmtlxx.wms.domain.PickOutWarehouseCode
 */
public interface SmartCabinetCodeMapper extends BaseMapperPlus<SmartCabinetCodeMapper, SmartCabinetCode, Object> {

    /**
     * 生成验证码
     *
     * @param type 类型
     * @param id   绑定id
     * @return void
     * @author hergreen
     * @date 2024/08/23 16:18
     */
    default boolean generateCode(Integer type, String id) {

        return this.insert(new SmartCabinetCode(type, id)) > 0;
    }

    /**
     * 批量生成验证码
     *
     * @param type 类型
     * @param ids  绑定ids
     * @return boolean
     * @author hergreen
     * @date 2024/10/09 15:00
     */
    default boolean batchGenerateCode(Integer type, List<String> ids) {

        List<SmartCabinetCode> smartCabinetCodes =
                ids.stream().map(item -> new SmartCabinetCode(type, item)).collect(Collectors.toList());

        return this.insertBatch(smartCabinetCodes);
    }

    /**
     * 获取最新验证码
     *
     * @param objId 绑定id
     * @param type  类型
     * @return com.xmtlxx.wms.domain.SmartCabinetCode
     * @author hergreen
     * @date 2024/10/10 14:10
     */
    SmartCabinetCode getNewestCode(@Param("objId") String objId, @Param("type") Integer type);

    /**
     * 获取智能柜出库验财物
     *
     * @param page 分页
     * @param ew   条件
     * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<VerifyOutProBo>
     * @author hergreen
     * @date 2024/10/10 18:10
     */
    @DataPermission({
            @DataColumn(key = "deptName", value = "t.dept_id"),
    })
    Page<VerifyOutProBo> getVerifyOutPro(@Param("page") Page<VerifyOutProBo> page, @Param(Constants.WRAPPER) Wrapper<Object> ew);

    /**
     * 获取一键开柜智能柜
     *
     * @param page
     * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.xmtlxx.wms.domain.bo.VerifyOutProBo>
     * @author hergreen
     * @date 2024/10/10 18:31
     */
    Page<VerifyOpenAllCabinetBo> getVerifyOpenAllCabinet(@Param("page") Page<VerifyOutProBo> page);

}




